package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TaskTemp;
import com.ruoyi.system.service.ITaskTempService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 为拧紧机服务的工单下发临时 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/taskTemp")
public class TaskTempController extends BaseController
{
    private String prefix = "system/taskTemp";
	
	@Autowired
	private ITaskTempService taskTempService;
	
	@RequiresPermissions("system:taskTemp:view")
	@GetMapping()
	public String taskTemp()
	{
	    return prefix + "/taskTemp";
	}
	
	/**
	 * 查询为拧紧机服务的工单下发临时列表
	 */
	@RequiresPermissions("system:taskTemp:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TaskTemp taskTemp)
	{
		startPage();
        List<TaskTemp> list = taskTempService.selectTaskTempList(taskTemp);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出为拧紧机服务的工单下发临时列表
	 */
	@RequiresPermissions("system:taskTemp:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TaskTemp taskTemp)
    {
    	List<TaskTemp> list = taskTempService.selectTaskTempList(taskTemp);
        ExcelUtil<TaskTemp> util = new ExcelUtil<TaskTemp>(TaskTemp.class);
        return util.exportExcel(list, "taskTemp");
    }
	
	/**
	 * 新增为拧紧机服务的工单下发临时
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存为拧紧机服务的工单下发临时
	 */
	@RequiresPermissions("system:taskTemp:add")
	@Log(title = "为拧紧机服务的工单下发临时", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TaskTemp taskTemp)
	{		
		return toAjax(taskTempService.insertTaskTemp(taskTemp));
	}

	/**
	 * 修改为拧紧机服务的工单下发临时
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		TaskTemp taskTemp = taskTempService.selectTaskTempById(id);
		mmap.put("taskTemp", taskTemp);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存为拧紧机服务的工单下发临时
	 */
	@RequiresPermissions("system:taskTemp:edit")
	@Log(title = "为拧紧机服务的工单下发临时", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TaskTemp taskTemp)
	{		
		return toAjax(taskTempService.updateTaskTemp(taskTemp));
	}
	
	/**
	 * 删除为拧紧机服务的工单下发临时
	 */
	@RequiresPermissions("system:taskTemp:remove")
	@Log(title = "为拧紧机服务的工单下发临时", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(taskTempService.deleteTaskTempByIds(ids));
	}
	
}
